<?php if (!defined('THINK_PATH')) exit();?><!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<meta name="renderer" content="webkit">
	    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
	    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
		<title>编辑客户</title>
		<link rel="stylesheet" href="/Public/frame/layui/css/layui.css">
			<!--<link rel="stylesheet" href="http://cdn.datatables.net/1.10.13/css/jquery.dataTables.min.css">-->
		<link rel="stylesheet" href="/Public/frame/static/css/style.css">
	</head>
	<body>
				<fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
          			<legend>客户资金记录</legend>
        		</fieldset>
        		<table class="layui-table" border="" cellspacing="" cellpadding="" width="100%">
	        		<thead>
		    			<tr>
		    				<td width="5%">序号</td>		                   
		    				<td width="8%">客户姓名</td>
		    				<td width="12%">资金操作类型</td>
		    				<td width="10%">操作资金额</td>
		    				<td width="10%">资金操作日期</td>
		    				<!-- <td width="15%">记录添加时间</td>  -->
		    				<td width="15%">专员分成</td>
		    				<td width="10%">主任分成</td>
		    				<td width="10%">经理分成</td>						
		    				<td width="5%">备注</td>
		    				<td width="15%">操作</td>
		    			</tr>
	    			</thead>
	    			<tbody>
<?php if(count($cusinfo['moneyLog']) > 0 ): foreach ($cusinfo['moneyLog'] as $k => $v):?>
						<tr>
							<td><?php echo $v['id'];?></td>
							<td><?php echo $v['cusname'];?></td>
							<td><?php echo $v['typeid'];?></td>
							<td><?php echo $v['opfare'];?></td>
							<td><?php echo $v['operate_time'];?></td>
							<!-- <td><?php echo $v['addtime'];?></td> -->
							<td><?php echo $v['divide_sale_worker'];?></td>
							<td><?php echo $v['divide_sale_head']?></td>
							<td><?php echo $v['divide_sale_manager']?></td>
							<td title="<?php echo $v['remark'];?>"><?php echo $v['remark']==''?'无':'有';?></td>
							<td>
								<a id="lst" class="layui-btn layui-btn-mini" lay-event="lst" uid="<?php echo $v['id'];?>">查看</a>
								<a id="edit" class="layui-btn layui-btn-normal layui-btn-mini" lay-event="edit" uid="<?php echo $v['id'];?>">修改</a>                
							    <a id="delete" class="layui-btn layui-btn-danger layui-btn-mini" lay-event="del" uid="<?php echo $v['id'];?>">删除</a>
							</td>
						</tr>

<?php endforeach;?>  
<?php if(preg_match('/\d/', $cusinfo['page'])): ?>  
        <tr><td align="right" nowrap="true" colspan="99" height="30" class="page"><?php echo $cusinfo['page']; ?></td></tr> 
<?php endif; ?> 
					</thead>
<?php else: ?>
					<tbody><tr><td align="center" nowrap="true" colspan="99" style="font-size:24px;padding:30px 0;">该客户还未订购产品</td></tr></tbody><?php endif; ?>
				</table>
		<fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
  			<legend>客户详细资料</legend>
		</fieldset> 		
		<form class="layui-form">
			<input type="hidden" name="id" value="<?php echo $cusinfo['id'];?>">
			<div class="layui-form-item">
			    <label class="layui-form-label">客户姓名</label>
			    <div class="layui-input-inline">
			      <input type="text" name="cusname" lay-verify="required" placeholder="请输入客户姓名" autocomplete="off" class="layui-input" value="<?php echo $cusinfo['cusname'];?>">
			    </div>
			</div>
			<div class="layui-form-item" >
			    <label class="layui-form-label">联系电话</label>
			    <div class="layui-input-inline">
			      <input type="text" name="tel" lay-verify="required" placeholder="请输入联系电话" autocomplete="off" class="layui-input" value="<?php echo $cusinfo['tel'];?>">
			    </div>
			</div>
			<div class="layui-form-item">
			    <label class="layui-form-label">地址</label>
			    <div class="layui-input-block">
			      <input type="text" name="address" lay-verify="title" autocomplete="off" placeholder="请输入地址" class="layui-input" value="<?php echo $cusinfo['address']==''?'无':$cusinfo['address'];?>">
			</div>
			<div class="layui-form-item" style="margin-top: 20px;">
			    <label class="layui-form-label">身份证号码</label>
			    <div class="layui-input-block">
			      <input type="text" name="ID_number" lay-verify="identity" placeholder="" autocomplete="off" class="layui-input" value="<?php echo $cusinfo['id_number'];?>">
			    </div>
			</div>
			<div class="layui-form-item" pane="">
			    <label class="layui-form-label">性别</label>
			    <div class="layui-input-block">
			      <input type="radio" name="sex" value="男" title="男" <?php echo $cusinfo['sex']=='男'? 'checked':''?>>
			      <input type="radio" name="sex" value="女" title="女" <?php echo $cusinfo['sex']=='女'? 'checked':''?>>
			    </div>
			</div>
			<div class="layui-form-item">
			    <label class="layui-form-label">年龄</label>
			    <div class="layui-input-inline">
			      <input type="text" name="age" placeholder="请输入客户年龄" autocomplete="off" class="layui-input" value="<?php echo $cusinfo['age'];?>">
			    </div>
			</div>
			<div class="layui-form-item">
			    <label class="layui-form-label">收单日期</label>
			    <div class="layui-input-inline">
			    	<input type="text" name="redate" id="date1" autocomplete="off" class="layui-input aaa" value="<?php echo $cusinfo['redate'];?>">
			    </div>
			</div>
			<div class="layui-form-item">
			    <div class="layui-inline">
			      <label class="layui-form-label">单号</label>
			      <div class="layui-input-inline">
			        <input type="text" name="odd_numbers" autocomplete="off" class="layui-input" value="<?php echo $cusinfo['odd_numbers'];?>">
			      </div>
			    </div>
		    </div>
		    <div class="layui-form-item">
		    	<div class="layui-inline">
		    		<label class="layui-form-label">资源来源</label>
		    		<div class="layui-input-inline">
		    			<select name="resource" lay-filter="aihao">
		    				<option value="">请选择</option>
		    				<?php foreach ($cusinfo['rtype'] as $k => $v): if ($v['name']==$cusinfo['resource']) $select = 'selected="selected"'; else $select = ''; ?>
		    				<option <?php echo ($select); ?> value="<?php echo ($v['name']); ?>"><?php echo ($v['name']); ?></option>
		    			<?php endforeach;?>
		    		</select>
		    	</div>
		    </div>
			</div>
		    <div class="layui-form-item">			    
			    <div class="layui-inline">
			      <label class="layui-form-label">资金量</label>
			      <div class="layui-input-inline">
			        <input type="text" name="financing" lay-verify="required" autocomplete="off" class="layui-input" value="<?php echo $cusinfo['financing'];?>">
			      </div>
			    </div>
			    <div class="layui-inline">
			      <label class="layui-form-label">产品名称</label>
			      <div class="layui-input-inline">
			        <input type="text" name="product_name" lay-verify="required" autocomplete="off" class="layui-input" value="<?php echo $cusinfo['product_name'];?>">
			      </div>
			    </div>
		    </div>
		    
		     <div class="layui-form-item">
			    <div class="layui-inline">
			      <label class="layui-form-label">服务时间</label>
			      <div class="layui-input-inline" style="width: 100px;">
			        <input type="text" name="server_time_start" lay-verify="required" id="date2"  autocomplete="off" class="layui-input" value="<?php echo $cusinfo['server_time_start'];?>">
			      </div>
			      <div class="layui-form-mid">-</div>
			      <div class="layui-input-inline" style="width: 100px;">
			        <input type="text" name="server_time_end" lay-verify="required" id="date3"  autocomplete="off" class="layui-input" value="<?php echo $cusinfo['server_time_end'];?>">
			      </div>
			    </div>
			  </div>
		
		       	<div class="layui-form-item">			    
				    <div class="layui-inline">
				      <label class="layui-form-label">部门</label>
				      <div class="layui-input-inline">
				        <input type="text" name="part" lay-verify="required" autocomplete="off" class="layui-input" disabled value="<?php echo $cusinfo['part_name'];?>">
				      </div>
				    </div>
				    <div class="layui-inline">
				      <label class="layui-form-label">业务员</label>
				      <div class="layui-input-inline">
				        <input type="text" name="sale_worker" lay-verify="required" autocomplete="off" class="layui-input" disabled value="<?php echo $cusinfo['sale_worker']?>">
				      </div>
				    </div>
		        </div>
		        <div class="layui-form-item layui-form-text">
				    <label class="layui-form-label">业务员备注</label>
				    <div class="layui-input-block">
				      <textarea placeholder="请输入内容" name="order_remark" class="layui-textarea"><?php echo $cusinfo['order_remark']==''?'无':$cusinfo['order_remark'];?></textarea>
				    </div>
				</div>
				<div class="layui-form-item">			    
				    <div class="layui-inline">
				      <label class="layui-form-label">销售主任</label>
				      <div class="layui-input-inline">
				        <input type="text" name="sale_head" lay-verify="required" autocomplete="off" class="layui-input" value="<?php echo $cusinfo['sale_head_name']?>">
				      </div>
				    </div>
				    <div class="layui-inline">
				      <label class="layui-form-label">销售经理</label>
				      <div class="layui-input-inline">
				        <input type="text" name="sale_manager" lay-verify="required" autocomplete="off" class="layui-input" value="<?php echo $cusinfo['sale_manager_name'];?>">
				      </div>
				    </div>
				   
		        </div>
		        <div class="layui-form-item">			    				 				  
				    <div class="layui-inline">
				      <label class="layui-form-label">商务经理</label>
				      <div class="layui-input-inline">
				        <input type="text" name="business_manager" lay-verify="required" autocomplete="off" class="layui-input" value="<?php echo $cusinfo['business_manager_name']?>">
				      </div>
				    </div>
				    <div class="layui-inline">
				      <label class="layui-form-label">商务专员</label>
				      <div class="layui-input-inline">
				        <input type="text" name="businesser" lay-verify="required" autocomplete="off" class="layui-input" value="<?php echo $cusinfo['businesser_name'];?>">
				      </div>
				    </div>
		        </div>
		        <div class="layui-form-item">			    				 				  
				    <div class="layui-inline">
					    <label class="layui-form-label">客户分类</label>
					    <div class="layui-input-block">
					      <select name="customer_type" lay-verify="required" lay-filter="aihao">
					        <option value="0">请选择</option>
					        <?php foreach ($type as $k => $v): if($v['name'] == $cusinfo['customer_type']) $select = 'selected="selected"'; else $select = ''; ?>
			    				<option <?php echo ($select); ?> value="<?php echo ($v["name"]); ?>"><?php echo ($v["name"]); ?></option>
			    			<?php endforeach; ?>
					      </select>
					    </div>
				    </div>
				    <div class="layui-inline">
				      <label class="layui-form-label">回单</label>
				      <div class="layui-input-inline">
				        <input type="text" name="receipt" autocomplete="off" class="layui-input" value="<?php echo $cusinfo['receipt']==''?'无':$cusinfo['receipt'];?>">
				      </div>
				    </div>
		        </div>
		        		        		        		        				
				<div class="layui-form-item layui-form-text">
				    <label class="layui-form-label">备注</label>
				    <div class="layui-input-block">
				      <textarea placeholder="请输入内容" name="remark" class="layui-textarea"><?php echo $cusinfo['remark']==''?'无':$cusinfo['remark'];?></textarea>
				    </div>
				</div>     		
	    </form>
	</body>
<script type="text/javascript" src="/Public/hawk/js/jquery-1.8.0.min.js"></script>
<script type="text/javascript" src="/Public/frame/layui/layui.js"></script>
	<script>
	$('#btn-refresh').on('click', function () {
            location.reload();
        });
	layui.use(['form', 'layedit', 'laydate'], function(){
	  var form = layui.form
	  ,layer = layui.layer
	  ,layedit = layui.layedit
	  ,laydate = layui.laydate;		
	  
	  //日期选择
	  laydate.render({
      elem: '#date1'
     });
      laydate.render({
      elem: '#date2'
     });
      laydate.render({
      elem: '#date3'
     });
     //弹出修改窗
     $(document).on('click','#edit',function(){
     	var cid= $(this).attr('uid');
     	layer.open({
     		type: 2,
     		title:'客户出入金修改',
     		area: ['80%', '80%'],
            fixed: false, //不固定
            maxmin: true,
            content: '/index.php/Hawk/Customer/moneyedit/id/'+cid
        });
     });
     //弹出该次分成详情窗
     $(document).on('click','#lst',function(){
     	var cid= $(this).attr('uid');
     	layer.open({
     		type: 2,
     		title:'客户该次出入金分成情况',
     		area: ['80%', '80%'],
            fixed: false, //不固定
            maxmin: true,
            content: '/index.php/Hawk/Customer/moneyinfo/id/'+cid
        });
     });
     //ajax删除客户资金操作记录
     $(document).on('click','#delete',function(){
     	var cid= $(this).attr('uid');
     	var $this = $(this);
     	layer.confirm('是否删除该条数据？', {icon: 3, title:'提示'}, function(index){
		  	$.post('/index.php/Hawk/Customer/moneydelete',{"id":cid},function(data){
	     		//console.log(data);return false;
	     		var obj = eval('(' + data + ')');
		    	if(obj.code==1){
		    		layer.msg(obj.msg);
		    		$this.parent().parent().remove();
		    	}else{
		    		layer.msg(obj.msg);
		    	}
     		});
		},function(index){
			layer.msg('你已取消。。。',{'icon':1});
		});
     	
     });

	});			
</script>
</html>